<%--
  Created by IntelliJ IDEA.
  User: qjqe@outlook.com
  Date: 2020/5/15
  Time: 9:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page import="java.util.List"%>
<head>
    <style type="text/css">
        #form{
            display: none;
        }
    </style>
</head>
<script>
    var status=0
    function report(a){
        $("#report").css("display","none");
        $("#form").attr('style','display:inline')
        status=a;
        /*


         */
    }
    //重新刷新
    function reload() {
        location.reload();
    }
    $(function () {
        $(".sure").click(function () {

            $.ajax(
                {
                    url: "/applies/add",
                    type: "post",
                    datatype:"json",
                    data:{"id":status,"introduce":$("#neirong").val() },
                    success: function (result) { //返回的结果自动放在resut里面了
                        if (result.status == "success") {//请求成功
                            alert("成功,请等待管理员审核");
                            location.reload();
                        }else if (result.status=="have"){
                            alert("已经提交过了，不能再提交了");
                        }
                        else {
                            alert("失败");
                            location.reload();
                        }
                    }
                });
        })
        $(".cancel").click(function () {
            $("#report").attr('style','display:inline')
            $("#form").attr('style','display:none');
        })
    })

</script>
<div id="report">
<h2 class="sub-header">通知列表</h2>
<div class="table-responsive">
    <table class="table table-striped">
        <thead>
        <tr>
            <th>编号</th>
            <th>标题</th>
            <!--<th>时间</th>-->
            <th>地点</th>
            <th>人数</th>
            <th>部门</th>

        </tr>
        </thead>
        <tbody>
        <c:forEach items = "${requestScope.recruitInfos }" var="recruitInfos">
            <tr>
                <td >${recruitInfos.infoid }</td>
                <td >${recruitInfos.name }</td>
                <td >${recruitInfos.place }</td>
                <td >${recruitInfos.number }</td>
                <td >${recruitInfos.deparmentid }</td>
                <th><button class="btn btn-default delete" onclick="report(${recruitInfos.infoid })">报名</button></th>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</div>
<div id="form">
    <div class="row">
    <h2 class="sub-header">部门申请</h2>
    <h3  class="text-center">申请理由</h3>
    <form class="form-horizontal">
        <textarea class="form-control" id="neirong" rows="4"></textarea>
    </form>
    <div style="float: right; margin-top: 50px;">
    <button type="button" class="btn btn-info btn-lg sure">确定</button>
    <button type="button" class="btn btn-default btn-lg cancel">取消</button>
     </div>
    </div>
</div>